/* 全局变量 */
:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #64748b;
    --background-color: #f8fafc;
    --chat-bg: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --success-color: #22c55e;
    --error-color: #ef4444;
    --header-height: 64px;
    --input-container-height: 120px;
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
}

/* 主容器 */
.container {
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    height: var(--header-height);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--chat-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.model-select {
    max-width: 200px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-color);
    background-color: var(--chat-bg);
    cursor: pointer;
    transition: border-color 0.2s;
}

.model-select:hover {
    border-color: var(--primary-color);
}

.model-info {
    font-size: 0.875rem;
    color: var(--text-light);
    white-space: nowrap;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background-color: var(--chat-bg);
    margin: 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--chat-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
}

.welcome-message h2 {
    color: var(--text-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.welcome-message p {
    color: var(--text-light);
    font-size: 1rem;
    margin: 0.5rem 0;
}

/* 消息样式 */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease-out;
}

.user-message {
    align-self: flex-end;
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ai-message {
    align-self: flex-start;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
    width: 100%;
}

.user-message .message-header {
    justify-content: flex-end;
}

.user-message .avatar {
    order: 1;
    margin-right: 0;
    margin-left: 0.5rem;
}

.user-message .timestamp {
    order: 0;
}

.avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    margin-right: 0.5rem;
}

.user-avatar {
    background-color: var(--primary-color);
    color: white;
}

.ai-avatar {
    background-color: var(--secondary-color);
    color: white;
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-light);
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-break: break-word;
}

.user-message .message-content {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
    display: inline-block;
    max-width: 100%;
    width: fit-content;
}

.ai-message .message-content {
    background-color: #e2e8f0;
    color: var(--text-color);
    border-bottom-left-radius: 0.25rem;
    display: inline-block;
    max-width: 100%;
    width: fit-content;
}

/* 输入区域 */
.chat-input-container {
    padding: 1rem;
    background-color: var(--chat-bg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 控制选项样式 */
.control-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 0.75rem 0;
    gap: 1rem;
}

/* 输入组样式 */
.input-group {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

#user-input {
    flex: 1;
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: none;
    transition: border-color 0.2s;
    background-color: var(--background-color);
    min-height: 100px;
    max-height: 200px;
}

#user-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

#send-button {
    padding: 0 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

#send-button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

#send-button:active {
    transform: translateY(0);
}

/* 加载动画 */
.thinking {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

.dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: var(--text-light);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 0.5rem;
}

.chat-messages::-webkit-scrollbar-track {
    background-color: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 0.25rem;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: var(--secondary-color);
}

/* 动画 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(0.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        height: 100%;
        margin: 0;
    }

    .chat-container {
        margin: 0;
        border-radius: 0;
    }

    .message {
        max-width: 90%;
    }

    .input-wrapper {
        flex-direction: column;
    }

    .control-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0 0 1rem 0;
    }
    
    .model-selector {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .model-select {
        width: 100%;
        max-width: none;
    }

    .toggle-switch {
        width: 100%;
    }

    .input-group {
        width: 100%;
    }

    #user-input {
        min-height: 60px;
    }

    #send-button {
        height: 2.5rem;
    }

    .chat-input-container {
        height: auto;
        padding: 0.75rem;
    }

    .user-message .message-content,
    .ai-message .message-content,
    .message-content.reasoning,
    .message-content.answer {
        max-width: 100%;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1e293b;
        --chat-bg: #0f172a;
        --text-color: #f1f5f9;
        --text-light: #94a3b8;
        --border-color: #334155;
    }

    .message-content.answer code {
        background-color: rgba(255, 255, 255, 0.1);
    }

    #user-input {
        background-color: #1e293b;
        color: var(--text-color);
    }

    .ai-message .message-content {
        background-color: #1a2234;
    }
}

/* 开关样式 */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.toggle-switch:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 2.5rem;
    height: 1.25rem;
    background-color: var(--border-color);
    border-radius: 1rem;
    margin-right: 0.5rem;
    transition: 0.4s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 1rem;
    width: 1rem;
    left: 0.125rem;
    bottom: 0.125rem;
    background-color: white;
    border-radius: 50%;
    transition: 0.4s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(1.25rem);
}

.toggle-label {
    font-size: 0.875rem;
    color: var(--text-color);
    white-space: nowrap;
}

/* 思考过程样式 */
.message-content.reasoning {
    font-size: 0.875rem;
    color: var(--text-light);
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--secondary-color);
    margin-bottom: 0.5rem;
    padding: 0;
    display: none;
    width: fit-content;
    max-width: 100%;
}

.reasoning-content {
    padding: 0.75rem 1rem;
    white-space: pre-wrap;
}

/* 思考中提示样式 */
.thinking-indicator {
    display: none;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background-color: rgba(100, 116, 139, 0.1);
    border-bottom: 1px solid var(--border-color);
}

.thinking-indicator span {
    color: var(--secondary-color);
    font-weight: 500;
}

.thinking-indicator .dot {
    width: 0.4rem;
    height: 0.4rem;
    background-color: var(--secondary-color);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.thinking-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* 回答样式 */
.message-content.answer {
    background-color: var(--chat-bg);
    color: var(--text-color);
    border-bottom-left-radius: 0.25rem;
    box-shadow: var(--shadow-sm);
    width: fit-content;
    max-width: 100%;
}

/* 代码块样式优化 */
.reasoning-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 0.25rem;
    margin: 0.5rem 0;
}

.reasoning-content code {
    font-size: 0.8125rem;
} 